import tkinter as tk

# 总数
def m_sum(a):
    return sum(map(int, a))

# 平均数
def m_averaged(a):
    return m_sum(a) / len(a)
# 方差
def m_variance(a):
    av = m_averaged(a)
    # 返回方差（当前数与平均数差的平方和）/总数
    return sum((int(x) - av) ** 2 for x in a) / len(a)

# 显示结果，方差越大越不稳定
def predict():
    s = data.get()
    arr = s.split()
    result.set(f'运动员稳定系数：{m_variance(arr)}')

root = tk.Tk()
root.title("运动员发挥的稳定性")

data = tk.Entry(root)
data.pack(side="left")
data.insert(0,"8 9 10 8 6 7")
button = tk.Button(root, text="预测", command=predict)
button.pack(side="left")
# 结果显示区
result = tk.StringVar()
label = tk.Label(root, textvariable=result)
label.pack()

root.mainloop()